<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="sf"%>

<c:set var="ctx" value="${pageContext.request.contextPath }" />
<link rel="stylesheet"
	href="${ctx }/resources/js/select2/select2.min.css" />

<script type="text/javascript"
	src="${ctx }/resources/js/select2/select2.min.js"></script>
<script type="text/javascript"
	src="${ctx }/resources/js/select2/zh-CN.js"></script>
<script type="text/javascript">
	$(function() {
		webside.form.bvideoweb.bvideowebForm();
	})
</script>

<%-- <script src="${basePath}/script/ajaxfileupload.js" type="text/javascript"></script>
  --%>

<script src="${ctx }/resources/js/upload/ajaxfileupload.js"
	type="text/javascript">
	
</script>
<style>
textarea {
	padding: 0px;
}
</style>
<script type="text/javascript">
	function limitChars() {
		var obj = document.getElementById("#introduction");
		if (obj.value.length > 1000) {
			obj.value = obj.value.substr(0, 1000);
		}
	}

	function moveOption(e1, e2) {
		var fromObjOptions = e1.options;
		for (var i = 0; i < fromObjOptions.length; i++) {
			if (fromObjOptions[i].selected) {
				e2.appendChild(fromObjOptions[i]);
				i--;
			}
		}
		document.myform.city.value = getvalue(document.myform.list2);
	}

	function doSaveLocalCoverUrl() {
		var fileName = $("#localCoverUrl").val();
		var type = fileName.split(".");
		var ftype = type[type.length - 1]; //获取文件后缀

		$.ajaxFileUpload({
			url : '${ctx}/files/upload/' + ftype,
			secureuri : false, //是否需要安全协议，一般设置为false
			fileElementId : [ 'localCoverUrl' ], //文件上传域的ID
			dataType : 'json', //返回值类型 一般设置为json
			success : function(data, status) //服务器成功响应处理函数
			{

				if (data.result == 0) {
					var fileId = data.data[0].id;
					var filePath = '/files/view/jpg/' + fileId;
					$("#hiddenLocalCoverUrl").val(filePath);
					//显示图片
					$("#imgLocalCoverUrl").attr("src",
							'${ctx }/files/view/jpg/' + fileId);
					//显示名字
					$("#laLocalCoverUrl").html(data.data[0].name);
				}
			},
			error : function(data, status, e) //服务器响应失败处理函数
			{
				alert(e);
			}
		});
	}
</script>

<div class="page-header">
	<h1>编辑预告片</h1>
</div>
<div class="row" style="margin-top: 5px;">
	<div class="col-xs-12">
		<!--  <form action="series/addinsert.html" id="addUI" name="addUI" class="form-horizontal" role="form" method="post">-->
		<form id="bvideowebForm" name="bvideowebForm" class="form-horizontal"
			role="form" method="post">
			<c:if test="${!empty videoFromWebEntity}">
				<input type="hidden" id="pageNum" name="pageNum"
					value="${page.pageNum }">
				<input type="hidden" id="pageSize" name="pageSize"
					value="${page.pageSize }">
				<input type="hidden" id="orderByColumn" name="orderByColumn"
					value="${page.orderByColumn }">
				<input type="hidden" id="orderByType" name="orderByType"
					value="${page.orderByType }">
				<input type="hidden" id='id' name="id"
					value="${videoFromWebEntity.id }">
			</c:if>

			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="title">标题</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="title" id="title" type="title"
							value="${videoFromWebEntity.title}" placeholder="标题" />
					</div>
				</div>
			</div>

			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right"
					for="description">描述</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="description" id="description"
							type="text" value="${videoFromWebEntity.description }"
							placeholder="描述.." maxlength='10' /> <label>最多输入10个字符</label>
					</div>
				</div>
			</div>

			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right"
					for="introduction">简介</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<textarea class="form-control" name="introduction"
							id="introduction" maxlength="1000" placeholder="简介.." rows="10"
							cols="10" onmousedown="s(event,this)"
							onchange="this.value=this.value.substring(0, 1000)"
							onkeydown="this.value=this.value.substring(0, 1000)"
							onkeyup="this.value=this.value.substring(0, 1000)">${videoFromWebEntity.introduction}</textarea>
						<label>最多只能输入1000个字符否则会输入不了字符，粘贴的会把超出的字符自动取消</label>
					</div>
				</div>
			</div>
			<input type="hidden" id='sourceCoverUrl' name="sourceCoverUrl"
				value="${videoFromWebEntity.sourceCoverUrl}"/> 
				<input type="hidden" id='status' name="status" value="${videoFromWebEntity.status}"/>

			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right"
					for="localCoverUrl">海报</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="files" id="localCoverUrl"
							type="file" placeholder="海报" /> <img id="imgLocalCoverUrl"
							alt=""
							<c:if test="${null eq  videoFromWebEntity.localCoverUrl}">src="${ctx}/resources/images/xx.png"</c:if>
							<c:if test="${videoFromWebEntity.localCoverUrl != null}">src="${ctx}${videoFromWebEntity.localCoverUrl}"</c:if>
							width="175px" height="100px"> <label id="laLocalCoverUrl"></label>
						<input type="button" id="but"
							onclick="javascript:doSaveLocalCoverUrl();" value="上传"
							class="btn btn-primary btn-sm" name="files" /> <input
							type="hidden" id="hiddenLocalCoverUrl" name="localCoverUrl" />
					</div>
					<label id='m' style='font-family: verdana; color: red'>海报尺寸比例要求16:9，推荐尺寸432
						*248</label>
				</div>
			</div>

			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="source">来源</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="source" id="source" type="text"
							value="${videoFromWebEntity.source }" placeholder="来源..." />
					</div>
				</div>
			</div>

			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right"
					for="timeDuration">时长</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="timeDuration" id="timeDuration"
							type="text" value="${videoFromWebEntity.timeDuration }"
							placeholder="时长..." />
					</div>
				</div>
			</div>

			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right"
					for="imgDefinition">清晰度</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<select id="imgDefinition" class="form-control"
							name='imgDefinition'>
							<option value=" "
								<c:if test="${videoFromWebEntity.imgDefinition eq null}">selected="selected"</c:if>>请选择</option>
							<c:forEach items="${clarity}" var="t">
								<option value="${t.code}"
									<c:if test="${videoFromWebEntity.imgDefinition eq t.code}">selected="selected"</c:if>>${t.name}</option>
							</c:forEach>
						</select>
					</div>
				</div>
			</div>

			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="type">分类</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="type" id="type" type="text"
							value="${videoFromWebEntity.type }" placeholder="分类..." />
					</div>
				</div>
			</div>

			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="type">详细页地址</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="detailUrl" id="detailUrl"
							type="text" value="${videoFromWebEntity.detailUrl }"
							placeholder="详细页地址..." />
					</div>
				</div>
			</div>

			<div class="form-group">
				<label class="control-label col-sm-1 no-padding-right" for="type">播放地址</label>
				<div class="col-sm-10">
					<div class="clearfix">
						<input class="form-control" name="playUrl" id="playUrl"
							type="text" value="${videoFromWebEntity.playUrl }"
							placeholder="详细页地址..." />
					</div>
				</div>
			</div>

			<input type="hidden" id='showDate' name="showDate"
				value="${videoFromWebEntity.showDate}">

		</form>
		<div class="hr hr-dotted"></div>
	</div>
</div>
<div class="center">
	<button id="btnAdd" type="button" onclick="show()"
		class="btn btn-success btn-sm">
		<i class="fa fa-user-plus"></i>&nbsp; 保存
	</button>
	<button id="btn" type="button"
		onclick="webside.common.loadPage('/bvideoweb/listUI.html<c:if test="${!empty videoFromWebEntity}">?page=${page.pageNum }&rows=${page.pageSize }&sidx=${page.orderByColumn }&sord=${page.orderByType }</c:if>')"
		class="btn btn-info btn-sm">
		<i class="fa fa-undo"></i>&nbsp;返回
	</button>
</div>

<script type="text/javascript">
	function show() {
		$('#bvideowebForm').submit();
	}
</script>